package deltax.common
{
    import flash.utils.*;

    final public class DictionaryUtil extends Object
    {
        private static var m_tempArrayToStoreDict:Array = [];
        private static var m_tempArrayForSort:Array = new Array();

        public function DictionaryUtil()
        {
            return;
        }// end function

        public static function copyDictionary(param1:Dictionary, param2:Dictionary = null) : Dictionary
        {
            var _loc_3:* = undefined;
            param2 = param2 || new Dictionary();
            if (param2)
            {
                clearDictionary(param2);
            }
            for (_loc_3 in param1)
            {
                
                param2[_loc_3] = param1[_loc_3];
            }
            return param2;
        }// end function

        public static function clearDictionary(param1:Dictionary) : void
        {
            var _loc_2:* = undefined;
            m_tempArrayToStoreDict.length = 0;
            for (_loc_2 in param1)
            {
                
                m_tempArrayToStoreDict.push(_loc_2);
            }
            for each (_loc_2 in m_tempArrayToStoreDict)
            {
                
                param1[_loc_2] = null;
                delete param1[_loc_2];
            }
            return;
        }// end function

        public static function isDictionaryEmpty(param1:Dictionary) : Boolean
        {
            var _loc_2:* = undefined;
            if (!param1)
            {
                return true;
            }
            for (_loc_2 in param1)
            {
                
                return false;
            }
            return true;
        }// end function

        public static function getDictionaryElemCount(param1:Dictionary) : uint
        {
            var _loc_3:* = undefined;
            if (!param1)
            {
                return 0;
            }
            var _loc_2:uint = 0;
            for (_loc_3 in param1)
            {
                
                _loc_2 = _loc_2 + 1;
            }
            return _loc_2;
        }// end function

        public static function getFirstElem(param1:Dictionary, param2:Boolean = true, param3:Function = null, param4:uint = 0)
        {
            var _loc_5:* = undefined;
            if (!param1)
            {
                return null;
            }
            if (param2)
            {
                m_tempArrayForSort.length = 0;
                for (_loc_5 in param1)
                {
                    
                    m_tempArrayForSort.push(param1[_loc_5]);
                }
                m_tempArrayForSort.sort(param3, param4);
                return m_tempArrayForSort.length > 0 ? (m_tempArrayForSort[0]) : (null);
            }
            else
            {
                for (_loc_5 in param1)
                {
                    
                    return param1[_loc_5];
                }
            }
            return null;
        }// end function

    }
}
